package com.itheima.health.controller;

import com.itheima.health.common.R;
import com.itheima.health.config.BeanContext;
import com.itheima.health.common.PageParam;
import com.itheima.health.common.ResultPageData;
import com.itheima.health.model.pojos.CheckItem;
import com.itheima.health.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkitem")
public class CheckItemController {
    @Autowired
    private BeanContext beanContext;

    @Autowired
    private CheckItemService checkItemService;
/*
* 检查项功能
* */
    @PostMapping("/findPage")
    public ResultPageData findPage(@RequestBody PageParam pageParam){
        ResultPageData resultPageData = checkItemService.findPage(pageParam);
        return resultPageData;
    }
    /*
    * 检查项新增
    * */
    @PostMapping("/add")
    public R addCheckItem(@RequestBody CheckItem checkItem){
        R r = checkItemService.addCheckItem(checkItem);
        return r;
    }
    /*
    * 检查项修改-回显
    * */
    @GetMapping("/findById")
    public R findCheckItemById(@RequestParam("id") Integer id){
        R r= checkItemService.findCheckItemById(id);
        return r;
    }
    /*
     * 检查项修改-更新
     * */
    @PostMapping("/edit")
    public R updateCheckItem(@RequestBody CheckItem checkItem){
        R r = checkItemService.updateCheckItem(checkItem);
        return r;
    }
    /*
    * 删除检查项
    * */
    @GetMapping("/delete")
    public R deleteCheckItem(@RequestParam("id") Integer id){
        R r = checkItemService.deleteCheckItem(id);
        return  r;
    }

    /*
     * 检查组新增-检查项信息回显
     * */
    @GetMapping("/findAll")
    public R getCheckGroupItemInfo(){
        R r = checkItemService.getCheckGroupItemInfo();
        return r;
    }

    /*
     * 检查组编辑-回显检查组关联的检查项
     * */
    @GetMapping("/findCheckItemIdsByCheckGroupId")
    public R findCheckItemIdsByCheckGroupId(@RequestParam("checkgroupId") Integer id){
        R r = checkItemService.findCheckItemIdsByCheckGroupId(id);
        return r;
    }


}
